package com.sport.facilities.booking.system.httptask;

import android.content.Context;

import com.sport.facilities.booking.system.htmlchecker.ConfirmBookingResultChecker;
import com.sport.facilities.booking.system.model.BookingRequestModel;

public class ConfirmBookingResultTask extends BasicTask {

	private final String TAG = "ConfirmBookingResultTask";

	public ConfirmBookingResultTask(Context ctx, OnTaskCompleted completeAction) {
		super(ctx);
		this.listener = completeAction;
	}

	public void fnConfirmBook(BookingRequestModel bkmodel) {
		try {
			super.onPreExecute();
			super.execute(PATH_POST_CONFIRM_BOOK, bkmodel);
		} catch (Exception e) {
			this.listener.onTaskFailed(e.getMessage());
		}
	}

	@Override
	protected void onPostExecute(String result) {
		super.onPostExecute(result);
		ConfirmBookingResultChecker cbrChecker = new ConfirmBookingResultChecker();
		boolean isConfirmSuccess = cbrChecker
				.getConfirmBookingResultfromHtml(result);
		if (isConfirmSuccess) {

			this.listener.onTaskCompleted(null);
		} else {

		}
	}
}
